package com.zsh.rabbitmq.six;

import com.rabbitmq.client.Channel;
import com.zsh.rabbitmq.utils.RabbitMQUtils;

import java.util.Scanner;

/**
 * @author zsh
 * @Description 直连模式，发送者
 * @create 2022-05-05 17:05
 */
public class EmitLog {

    //交换机名称
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();



        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String msg = scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"error",null,msg.getBytes("UTF-8"));
            System.out.println("生产者发出消息：" + msg);
        }

    }
}
